package com.vcit.system.service.term.impl;

import java.util.List;

import com.vcit.common.core.domain.model.LoginUser;
import com.vcit.common.utils.DateUtils;
import com.vcit.common.utils.SecurityUtils;
import com.vcit.system.domain.term.Term;
import com.vcit.system.mapper.term.TermMapper;
import com.vcit.system.service.term.TermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 学期Service业务层处理
 *
 * @author dff
 * @date 2025-01-17
 */
@Service
public class TermServiceImpl implements TermService
{
    @Autowired
    private TermMapper termMapper;

    /**
     * 查询学期
     *
     * @param id 学期主键
     * @return 学期
     */
    @Override
    public Term selectTermById(Long id)
    {
        return termMapper.selectTermById(id);
    }

    /**
     * 查询学期列表
     *
     * @param term 学期
     * @return 学期
     */
    @Override
    public List<Term> selectTermList(Term term)
    {
        return termMapper.selectTermList(term);
    }

    /**
     * 新增学期
     *
     * @param term 学期
     * @return 结果
     */
    @Override
    public int insertTerm(Term term)
    {
        // 获取当前用户名
        String username = SecurityUtils.getUsername();
        term.setCreateTime(DateUtils.getNowDate());
        term.setCreateBy(username);
        return termMapper.insertTerm(term);
    }

    /**
     * 修改学期
     *
     * @param term 学期
     * @return 结果
     */
    @Override
    public int updateTerm(Term term)
    {
        String username = SecurityUtils.getUsername();
        term.setUpdateBy(username);
        term.setUpdateTime(DateUtils.getNowDate());
        return termMapper.updateTerm(term);
    }

    /**
     * 批量删除学期
     *
     * @param ids 需要删除的学期主键
     * @return 结果
     */
    @Override
    public int deleteTermByIds(Long[] ids)
    {
        return termMapper.deleteTermByIds(ids);
    }

    /**
     * 删除学期信息
     *
     * @param id 学期主键
     * @return 结果
     */
    @Override
    public int deleteTermById(Long id)
    {
        return termMapper.deleteTermById(id);
    }
}